package com.yjjxt

import org.apache.spark.{SparkConf, SparkContext}

object Hello13ForeachPartition {
  def main(args: Array[String]): Unit = {
    val sparkContext = new SparkContext((new SparkConf().setMaster("local").setAppName("Join" + System.currentTimeMillis())))
    val array1 = Array[String]("Hello1 user11", "Hello1 user12", "Hello user11", "Hello user12", "user1 apple1")
    val lines1 = sparkContext.parallelize(array1, 3)
    lines1.foreachPartition(iter => {
      val random: Double = Math.random()
      while (iter.hasNext) {
        println("iter" + random + "-->" + iter.next())
      }
    })
  }
}
